/*提交表单*/
function sendForm(formId, check,gourl, mode) {
	if(typeof formId == 'object') {
		var btn = formId;
		form = btn.closest('form');
		btn.addClass('disabled').data('txt', btn.text()).html("<i class='ace-icon fa fa-spinner fa-pulse'></i> 处理中...").prop('disabled', true);

	} else {
		form = $("#" + formId);
	}

	//检查
	check = check ? check : form.data('check');
	mode = mode ? mode : form.data('mode');
	if(check && !checkForm(form)) {
		btn.removeClass('disabled').text(btn.data('txt')).prop('disabled', false);
		return false;
	}
	post_url = form.prop('action');
	if(form.data('ajax')) {
		//		var vars = $("#" + formId).serialize();
		var vars = new FormData(form[0]);
		Load();
		$.ajax({
			type: "POST",
			url: post_url,
			data: vars,
			contentType: false,
			processData: false,
			//			dataType : "json",
			success: function(res) {
				console.log(res);
				if(res.code == 0) {
					if(btn) {
						btn.removeClass('disabled').text(btn.data('txt')).prop('disabled', false);
					}
				};
				if(res.data && res.data.tip && !res.code) {
					var tipt = $('#' + res.data['tip']);
					Tips(res.msg, tipt);
					tipt.closest('.form-group').addClass('has-error');

				} else {
					if(gourl){
						res.url=gourl
					}
					rslt(res, mode);
				};
				btn.removeClass('disabled').text(btn.data('txt')).prop('disabled', false);
				Load(1);
			},
			error: function(res1) {
				console.log(res1)
				Load(1)
				Err('请求失败，错误：readyState：' + res1.readyState)
				btn.removeClass('disabled').text(btn.data('txt')).prop('disabled', false);
			}
		});
	} else {
		//		$("#" + formId).attr("action", post_url);
		if(!form.prop('method')) form.prop('method', 'post');
		form.submit();
	}
}

function Tips(msg, target, err) {
	Err(msg ? msg : '操作失败，稍候再试');
}

function goTo(url, newopen) {
	if(url == -1) {
		history.back();
	} else if(url == 0) {
		return false
	} else if(url == 1) {
		window.location.reload();
	} else if(url) {
		if(newopen) {
			window.open(url);
		} else {
			window.location.href = url;
		}

	}
}

function rslt(res, mode, formId) {
	var newopen = 0;
	var mode = 1;
	
	//	Load(1);

	if(res.code) {
		rmsg = res.msg ? res.msg : '操作成功！';
		url = res.url ? res.url : res.data.url;

		if(mode) {
			Msg(rmsg);
			setTimeout(function() {
				goTo(url);
			}, 1000)
		} else {}

	} else {
		Err(res.msg ? res.msg : '操作失败，稍候再试');

	}
}

function checkForm(formId) {

	var check_flag = true;

	if(typeof formId == 'object') {
		form = formId;
	} else {
		form = $("#" + formId);
	}

	form.find(":input").each(function(i) {
		if($(this).data("check")) {
			var v;
			if($(this).prop('type') == 'checkbox' || $(this).prop('type') == 'radio') {
				v = $(this).prop('checked');
			} else {
				v = $(this).val();
			}
			if(!validate(v, $(this).data("check"))) {

				$(this).data("msg", $(this).data("msg") ? $(this).data("msg") : $(this).prop("placeholder"));
				if($(this).data("msg").indexOf("|")) {
					tmp = $(this).data("msg").split("|");
					msgtype = tmp[1];
					msg = tmp[0];
				}

				if(msgtype == 'popup') {
					LErr(tmp[0]);
				} else {

					Tips($(this).data("msg"), $(this), 1);
					$(this).focus();
					$(this).closest('label').addClass('has-error');
				}
				//提示
				check_flag = false;
				return check_flag;
			} else {
				//				$(this).closest('label').replaceClass('has-error','has-success');
				$(this).parent().next().html('')
			}
		}
	})
	return check_flag;
};

/* 验证数据类型*/
function validate(data, datatype) {
	if(datatype.indexOf("|")) {
		tmp = datatype.split("|");
		datatype = tmp[0];
		data2 = tmp[1];
	}
	switch(datatype) {
		case "require":
			if(!data) {
				return false;
			} else {
				return true;
			}
			break;
		case "email":
			var reg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
			return reg.test(data);
			break;
		case "mobile":
			var reg = /^1[34578]\d{9}$/g;
			return reg.test(data);
			break;
		case "number":
			var reg = /^[0-9]+\.{0,1}[0-9]{0,3}$/;
			return reg.test(data);
			break;
		case "html":
			var reg = /<...>/;
			return reg.test(data);
			break;
		case "gt":
			return data > data2
			break;
		case "notgt":
			return data <= data2
			break;
		case "lt":
			return data < data2
			break;
		case "notlt":
			return data >= data2
			break;
		case "eqt":
			data2 = $("#" + data2).val();
			return data >= data2
			break;
		case "password":
			var reg = /^.{6,16}$/;
			return reg.test(data);
			break;
		case "username":
			var reg = /^[a-z][0-9a-z]{4,}$/g;
			return reg.test(data);
			break;
		case "nickname":
			var reg = /^.{4,}$/g;
			return reg.test(data);
			break;
		case "code":
			var reg = /^[0-9]{4}$/;
			return reg.test(data);
			break;
	}
}

function Msg(msg, func) {
	layer.msg(msg, {
		icon: 1
	}, func);
}

function Err(msg) {
	layer.msg(msg, {
		icon: 2
	});
}

function Load(close) {
	if(close) {
		layer.closeAll('loading');
	} else {
		layer.load(0, {
			shade: false,
		});
	}
};
//点击弹出框
function popup(obj, url, number) {
	console.log(url)
	var active = {
		//删除单个
		delete: function(othis, number, url) {
			var type = othis.data('type'),
				text = othis.text();

			layer.open({
				type: 1,
				title: false,
				offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
					,
				id: "delete" //防止重复弹出
					,
				content: "<div class='am-vertical-align-middle' style='width:100%;text-align:center'>是否删除</div>",
				btn: ['确定', '取消'],
				btnAlign: 'c' //按钮居中
					,
				shade: 0 //不显示遮罩
					,
				yes: function() {
					console.log(othis.closest('tr').data('id'))
					var data = {
						id: othis.closest('tr').data('id')
					};
					var deleteload = layer.load(1, {
						shade: [0.1, '#fff'] //0.1透明度的白色背景
					});
					$.ajax({
						method: "POST",
						url: url,
						data: data,
						success: function(res) {
							if(res.code == 1) {
								layer.close(deleteload);
								othis.closest('tr').remove();
								layer.closeAll();
								
							} else if(res.code == 0) {
								layer.close(deleteload);
								Err(res.msg ? res.msg : '操作失败，稍候再试');
							}

						}
					});

				},
				btn2: function() {
					layer.closeAll();
				}
			});
		},
		//删除多个
		deleteMultiple: function(othis, number, url) {
			var type = othis.data('type'),
				text = othis.text();

			layer.open({
				type: 1,
				title: false,
				offset: type ,
				id: "delete" ,
				content: "<div class='am-vertical-align-middle' style='width:100%;text-align:center'>是否删除</div>",
				btn: ['确定', '取消'],
				btnAlign: 'c' //按钮居中
					,
				shade: 0 //不显示遮罩
					,
				yes: function() {
					var deletearr = []
					console.log($(othis).parent().next('table'))
					for(var deleteidx = 0; deleteidx < $('table').find('.check-list').length; deleteidx++) {
						if($('table').find('.check-list')[deleteidx].checked) {
							deletearr.push($('table').children('tbody').find('tr').eq(deleteidx).data('id'))
						}
					}

					var data = {
						id: deletearr
					};
					console.log(data)
					var deleteload = layer.load(1, {
						shade: [0.1, '#fff'] //0.1透明度的白色背景
					});
					$.ajax({
						method: "POST",
						url: url,
						data: data,
						success: function(res) {
							if(res.code == 1) {
								layer.close(deleteload);
								layer.closeAll();
								rslt(res)
								window.history.go(0)
							} else if(res.code == 0) {
								layer.close(deleteload);
								Err(res.msg ? res.msg : '操作失败，稍候再试');
							}

						}
					});

				},
				btn2: function() {
					layer.closeAll();
				}
			});
		},
		//取消
		cancel: function(othis, number, url) {
			var type = othis.data('type'),
				text = othis.text();

			layer.open({
				type: 1,
				title: false,
				offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
					,
				id: "delete" //防止重复弹出
					,
				content: "<div class='am-vertical-align-middle' style='width:100%;text-align:center'>是否取消该订单</div>",
				btn: ['确定', '取消'],
				btnAlign: 'c' //按钮居中
					,
				shade: 0 //不显示遮罩
					,
				yes: function() {
					console.log(othis.closest('tr').data('id'))
					var data = {
						id: othis.closest('tr').data('id'),
						state: 12
					};
					var deleteload = layer.load(1, {
						shade: [0.1, '#fff'] //0.1透明度的白色背景
					});
					$.ajax({
						method: "POST",
						url: url,
						data: data,
						success: function(res) {
							console.log(res)
							if(res.code == 1) {
								layer.close(deleteload);
								layer.closeAll();
								window.history.go(0)
							} else if(res.code == 0) {
								layer.close(deleteload);
								Err(res.msg ? res.msg : '操作失败，稍候再试');
							}

						}
					});

				},
				btn2: function() {
					layer.closeAll();
				}
			});
		},
		//同意
		consent: function(othis, number, url) {
			var type = othis.data('type'),
				text = othis.text();

			layer.open({
				type: 1,
				title: false,
				offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
					,
				id: "consent" //防止重复弹出
					,
				content: "<div class='am-vertical-align-middle' style='width:100%;text-align:center'>是否同意该订单</div>",
				btn: ['确定', '取消'],
				btnAlign: 'c' //按钮居中
					,
				shade: 0 //不显示遮罩
					,
				yes: function() {
					console.log(othis.closest('tr').data('id'))
					var data = {
						id: othis.closest('tr').data('id'),
						state: 4
					};
					var deleteload = layer.load(1, {
						shade: [0.1, '#fff'] //0.1透明度的白色背景
					});
					$.ajax({
						method: "POST",
						url: url,
						data: data,
						success: function(res) {
							console.log(res)
							if(res.code == 1) {
								layer.close(deleteload);
								layer.closeAll();
								window.history.go(0)
							} else if(res.code == 0) {
								layer.close(deleteload);
								Err(res.msg ? res.msg : '操作失败，稍候再试');
							}

						}
					});

				},
				btn2: function() {
					layer.closeAll();
				}
			});
		},

		//拒绝
		repulse: function(othis, number, url) {
			var type = othis.data('type'),
				text = othis.text();

			layer.open({
				type: 1,
				title: false,
				offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
					,
				id: "repulse" //防止重复弹出
					,
				content: "<div class='am-vertical-align-middle' style='width:100%;text-align:center'>是否拒绝该订单</div>",
				btn: ['确定', '取消'],
				btnAlign: 'c' //按钮居中
					,
				shade: 0 //不显示遮罩
					,
				yes: function() {
					console.log(othis.closest('tr').data('id'))
					var data = {
						id: othis.closest('tr').data('id'),
						state: 3
					};
					var deleteload = layer.load(1, {
						shade: [0.1, '#fff'] //0.1透明度的白色背景
					});
					$.ajax({
						method: "POST",
						url: url,
						data: data,
						success: function(res) {
							console.log(res)
							if(res.code == 1) {
								layer.close(deleteload);
								layer.closeAll();
								window.history.go(0)
							} else if(res.code == 0) {
								layer.close(deleteload);
								Err(res.msg ? res.msg : '操作失败，稍候再试');
							}

						}
					});

				},
				btn2: function() {
					layer.closeAll();
				}
			});
		},

		//启用单个
		startusing: function(othis, number, url) {
			var type = othis.data('type'),
				text = othis.text();

			layer.open({
				type: 1,
				title: false,
				offset: type,
				id: "delect",
				content: "<div class='am-vertical-align-middle' style='width:100%;text-align:center'>是否启用</div>",
				btn: ['确定', '取消'],
				btnAlign: 'c' //按钮居中
					,
				shade: 0 //不显示遮罩
					,
				yes: function() {
					var data = {
						id: othis.closest('tr').data('id'),
						state: 1
					};
					var startusingload = layer.load(1, {
						shade: [0.1, '#fff'] //0.1透明度的白色背景
					});
					$.ajax({
						method: "POST",
						url: url,
						data: data,
						success: function(res) {
							if(res.code == 1) {
								layer.closeAll();
								window.history.go(0)
							} else if(res.code == 0) {
								layer.close(startusingload);
								Err(res.msg ? res.msg : '操作失败，稍候再试');
							}

						}
					});

				},
				btn2: function() {
					layer.closeAll();
				}
			});
		},
		//禁用单个
		forbidden: function(othis, number, url) {
			var type = othis.data('type'),
				text = othis.text();

			layer.open({
				type: 1,
				title: false,
				offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
					,
				id: "delect" //防止重复弹出
					,
				content: "<div class='am-vertical-align-middle' style='width:100%;text-align:center'>是否禁用</div>",
				btn: ['确定', '取消'],
				btnAlign: 'c' //按钮居中
					,
				shade: 0 //不显示遮罩
					,
				yes: function() {
					var forbiddenload = layer.load(1, {
						shade: [0.1, '#fff'] //0.1透明度的白色背景
					});
					var data = {
						id: othis.closest('tr').data('id'),
						state: 9
					};
					$.ajax({
						method: "POST",
						url: url,
						data: data,
						success: function(res) {
							if(res.code == 1) {
								layer.closeAll();
								window.history.go(0)
							} else if(res.code == 0) {
								layer.close(forbiddenload);
								Err(res.msg ? res.msg : '操作失败，稍候再试');
							}

						}
					});
				},
				btn2: function() {
					layer.closeAll();
				}
			});
		},
		showmap: function(othis) {
			var type = othis.data('type'),
				text = othis.text();

			layer.open({
				type: 1,
				area: ['60%', '60%'],
				title: false,
				offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
					,
				id: 'layerDemo' + type //防止重复弹出
					,
				content: '<div id="showlocation" style="width:99%;height:99%;margin:1%"></div>',
				btn: ['确认'],
				success: function(layero) {
					var btn = layero.find('.layui-layer-btn');
					//					layer.closeAll();
				},
				btn2: function() {
					layer.closeAll();
				},
				btnAlign: 'c' //按钮居中
					,
				shade: 0 //不显示遮罩
					,
				yes: function() {
					layer.closeAll();
				}
			});
		}

	}

	var othis = $(obj),
		method = othis.data('method');
	active[method] ? active[method].call(obj, othis, number, url) : '';

};

//全选
function checkall(obj) {
	var idname = $(obj).closest('table').attr('id')
	if($(obj).data('checkall')) {
		for(var i = 0; i < $('#' + idname + ' tbody input[type="checkbox"]').length; i++) {
			$('#' + idname + ' tbody input[type="checkbox"]')[i].checked = obj.checked
		}
	} else {
		var ispitchon = true
		for(var i = 0; i < $('#' + idname + ' tbody input[type="checkbox"]').length; i++) {
			if($('#' + idname + ' tbody input[type="checkbox"]')[i].checked) {

			} else {
				ispitchon = false
			}
		}
		if(ispitchon) {
			$('table thead input')[0].checked = true
		} else {
			$('table thead input')[0].checked = false
		}
	}
};
//选择车辆
function choosecar(url) {
	console.log(url)
	layer.open({
		type: 2,
		title: '请选择',
		shadeClose: true,
		shade: 0.8,
		area: ['80%', '70%'],
		content: url //iframe的url
	});
}

function choosecar2(url) {
	console.log(url)
	layer.open({
		type: 2,
		title: '请选择',
		shadeClose: true,
		shade: 0.8,
		area: ['90%', '80%'],
		content: url //iframe的url
	});
}
//公司部门编辑
function department(url, msg) {
	layer.open({
		type: 2,
		title: msg ? msg : '请选择',
		shadeClose: true,
		shade: 0.8,
		area: ['50%', '70%'],
		content: url //iframe的url
	});
}
//exit编辑
function exitchang(url) {
	console.log(url)
	layer.open({
		type: 2,
		title: '修改',
		shadeClose: true,
		shade: 0.8,
		area: ['90%', '90%'],
		content: url //iframe的url
	});
}
//上传图片前预览
//function preview(file) {
//	if($(file).data('dwd')) {} else {
//		var prevDiv = $(file).closest('.showimg').children('div')[0];
//
//		if(file.files && file.files[0]) {
//			var reader = new FileReader();
//			reader.onload = function(evt) {
//				prevDiv.innerHTML = '<img src="' + evt.target.result + '" alt="车辆正面"/>';
//			}
//			reader.readAsDataURL(file.files[0]);
//		} else {
//			prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
//		}
//	}
//}

//时间判断
function datejudge(obj1, obj2) {
	if(obj1) {
		if(obj2) {
			var dat1 = obj1.val()
			var dat2 = obj2.val()
			dat1 = new Date(dat1)
			dat2 = new Date(dat2)
			if(dat1 > dat2) {
				Err('开始时间要在结束时间之前')
				return false
			}else{
				return true
			}
		}
	}
}

//表格内容
//res 请求返回的值
//arr 所需要展示的数据的key值的集合
//id 需插入的表格的id
//nomessage 没有值的时候显示的
//ischeck 是否有多选
//trdatakey 表格tr节点上时候有需要添加的data属性 的key  data-key
//trdatakeyval 表格tr节点上时候有需要添加的data-key属性 的value
function tbody(res, arr, id, nomessage, ischeck, trdatakey, trdatakeyval) {
	var main = '';

	for(var i = 0; i < res.data.list.length; i++) {
		main += `<tr`
		if(trdatakey) {
			for(var tridx = 0; tridx < trdata.length; trdata++) {
				if(tridx == trdata.length - 1) {
					main += ` data-${trdatakey[tridx]}:${res.data.list[i][trdatakeyval[tridx]]}>`
				} else {
					main += ` data-${trdatakey[tridx]}:${res.data.list[i][trdatakeyval[tridx]]}`
				}
			}
		} else {
			main += `>`
		}
		//			main += `<tr>`
		if(ischeck) {
			main += `<td><input type="checkbox" class="check-list"></td>`
		}
		for(var j = 0; j < arr.length; j++) {
			main += `<td>${res.data.list[i][arr[j]]?res.data.list[i][arr[j]]:nomessage}</td>`
		}
		main += `</tr>`
	}
	$('#' + id).find('tbody').html(main)
}

//下拉选项
function selectmain(num,res){
	var  selectlist="";
	for (var i=0;i<res.length;i++){
		selectlist+=`<option value='${i+1}'>${res[i]}</option>`
	}
	return selectlist
}

//根据id查找列表中的相符的数据
function getdetail(id,res,id_name){
	for(var i=0;i<res.length;i++){
		if(res[i][id_name]==id){
			return res[i]
		}
	}
}

//订单状态转换
function orderstate(res){
	for(var i=0;i<res.data.length;i++){
		if(res.data[i].order_type){
			if(res.data[i].order_type==1){
				res.data[i].order_type2='公务订单'
			}else if(res.data[i].order_type==2){
				res.data[i].order_type2='企业订单'
			}else if(res.data[i].order_type==3){
				res.data[i].order_type2='个人订单'
			}
		}
		if(res.data[i].order_type){
			if(res.data[i].booking_type==1){
				res.data[i].booking_type2='日常用车'
			}else if(res.data[i].booking_type==2){
				res.data[i].booking_type2='包车'
			}else {
				res.data[i].booking_type2='未获取订车类型'
			}
		}
		if(res.data[i].order_state){
			if(res.data[i].order_state==1){
				res.data[i].order_state2='待审批'
			}else if(res.data[i].order_state==2){
				res.data[i].order_state2='已批准'
			}else if(res.data[i].order_state==3){
				res.data[i].order_state2='已拒绝'
			}else if(res.data[i].order_state==4){
				res.data[i].order_state2='待用车'
			}else if(res.data[i].order_state==5){
				res.data[i].order_state2='已派车'
			}else if(res.data[i].order_state==6){
				res.data[i].order_state2='接驾中'
			}else if(res.data[i].order_state==7){
				res.data[i].order_state2='已到达出发地'
			}else if(res.data[i].order_state==8){
				res.data[i].order_state2='已到达目的地'
			}else if(res.data[i].order_state==9){
				res.data[i].order_state2='待支付'
			}else if(res.data[i].order_state==10){
				res.data[i].order_state2='待评价'
			}else if(res.data[i].order_state==11){
				res.data[i].order_state2='已完成'
			}else if(res.data[i].order_state==12){
				res.data[i].order_state2='已取消'
			}else if(res.data[i].order_state==13){
				res.data[i].order_state2='已终止'
			}else if(res.data[i].order_state==14){
				res.data[i].order_state2='无效'
			}
		}
		
		if(res.data[i].use_type){
			if(res.data[i].use_type==1){
				res.data[i].use_type2='行政执法'
			}else if(res.data[i].use_type==2){
				res.data[i].use_type2='特殊公务'
			}else if(res.data[i].use_type==3){
				res.data[i].use_type2='重要会议'
			}else if(res.data[i].use_type==4){
				res.data[i].use_type2='机要通讯'
			}else if(res.data[i].use_type==5){
				res.data[i].use_type2='视察调研'
			}else if(res.data[i].use_type==6){
				res.data[i].use_type2='公务接待'
			}else if(res.data[i].use_type==7){
				res.data[i].use_type2='应急公务'
			}else if(res.data[i].use_type==8){
				res.data[i].use_type2='紧急就医'
			}else{
				res.data[i].use_type2='未获取用车类型'
			}
		}

        if(res.data[i].meter){
            res.data[i].meter = (res.data[i].meter / 1000).toFixed(2) + '公里'
		}

        if(res.data[i].use_time !== undefined){
            res.data[i].use_time = formatTime( res.data[i].use_time )
        }
	}
	return res
}

function formatTime(time) {
    let day = parseInt(time / (24 * 60 * 60));
    let left = time % (24 * 60 * 60);
    let hour = parseInt(left / (60 * 60));
    left = left % (60 * 60);
    let min = parseInt(left / 60);
    let second = left % 60;

    if(day) return day + "天" + hour + "小时" + min + "分钟" +second  + "秒";
    if(hour) return hour + "小时" + min + "分钟" + second + "秒";
    if(min) return min + "分钟" + second + "秒";
    if(second) return second + "秒";
    return '--';
}

function driverstate(res){
	for(var i=0;i<res.data.length;i++){
		if(res.data[i].work_state){
			if(res.data[i].work_state==1){
				res.data[i].work_state2='执行任务中'
			}else if(res.data[i].work_state==2){
				res.data[i].work_state2='有预约订单'
			}else if(res.data[i].work_state==3){
				res.data[i].work_state2='听单中'
			}else{
				res.data[i].work_state2='下班'
			}
		}
		if(res.data[i].state){
			if(res.data[i].state==1){
				res.data[i].state2='启用'
			}else {
				res.data[i].state2='禁用'
			}
		}
	}
	return res
}
function exports(res,tddata,data,url){
	var getkey="";
	for(var iii=0;iii<tddata.length;iii++){
		for(var key in res.description){
			if(key==tddata[iii].key){
				tddata[iii].text=res.description[key].name
			}
		}
		getkey+=`<li>
				<label class="am-checkbox">
			      <input type="checkbox" value="" data-key='${tddata[iii].key}' checked> ${tddata[iii].text}
			    </label>
			</li>`
	}
	let layerIndex = layer.open({
	  	type: 1,
	  	title:false,
	  	skin: 'layui-layer-rim', //加上边框
	  	area: ['300px', '400px'], //宽高
	  	content: `<div>
	 				<div style='height:300px;overflow:auto;margin-bottom:30px'>
				  	<ul class='daochuul'>${getkey}</ul>
				  	</div>
				  	<div style='text-align:center'>
				  		<button class='am-btn am-btn-sm am-btn-primary am-radius daochu_ok' type='button'>确定导出</button>
				  		<button class='am-btn am-btn-sm am-btn-primary am-radius export-cancel' type='button'>取消</button>
				  	</div>
				</div>`,
		success:function(){
			var ddata={
				fields:''
			}
			$('.daochu_ok').on('click',function(){
				$('.daochuul li input[type="checkbox"]').each(function(){
					if(this.checked){
						ddata.fields+=($(this).data('key')+",")
					}
				})
				ddata.fields=ddata.fields.slice(0,ddata.fields.length-1)

				setTimeout(function(){
                    layer.close(layerIndex);
				}, 500);

				window.open(`${url}?where_json=${data.where_json}&fields=${ddata.fields}`)
//								
			})

			$('.export-cancel').on('click', function(){
                layer.close(layerIndex);
			});
			
		}
	});
}

